<?php
// +----------------------------------------------------------------------
// | Name: keAdmin
// | Author King east To 1207877378@qq.com
// +----------------------------------------------------------------------

namespace app\common\behavior;


use app\common\model\Site;
use think\Cache;

class ReadSiteInfo
{
    public function run(&$request)
    {
        $siteInfo=Cache::get('siteInfo');
        if(empty($siteInfo)){
            $siteInfo=Site::where('use',1)->find();
            if(!$siteInfo){
                $siteInfo=new Site;
                $siteInfo->use=1;
                $siteInfo->title='默认站点';
                $siteInfo->keywords='';
                $siteInfo->description='';
                $siteInfo->save();
            }
            $siteInfo=$siteInfo->toArray();
            Cache::set('siteInfo',$siteInfo,86400*30);
            $request->siteInfo=$siteInfo;
        }else{
            $request->siteInfo=$siteInfo;
        }



    }

}